<?php
/**
 * Created by PhpStorm.
 * User: DD
 * Date: 2016/4/18
 * Time: 17:12
 */

namespace app\admin\controller;


use app\admin\services\AdminService;
use app\admin\services\RoleService;
use app\common\controller\Base;

class Admin extends Base
{
    /**
     * @var AdminService
     */
    protected $_service;

    protected function _setService()
    {
        $this->_service = new AdminService();
    }

    public function index()
    {
        return $this->fetch();
    }

    public function saveRoles()
    {
        $uid = I('post.uid', 0, 'intval');
        $rids = I('post.rids', '', 'trim');
        if ($this->_service->saveRoles($uid, $rids)) {
            return $this->jsonSuccess();
        }
        return $this->jsonFail();
    }

    public function changePwd()
    {
        return $this->commonData($this->_service->changePwd($_POST));
    }

}